import Vue from "vue";
import Router from "vue-router";

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router);

/* Layout */
import Layout from "../views/layout/Layout";

/**
* hidden: true                   if `hidden:true` will not device in the sidebar(default is false)
* alwaysShow: true               if set true, will always device the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not device the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name device in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon device in the sidebar,
  }
**/
export const constantRoutes = [{
        path: "/login",
        component: () =>
            import ("@/views/login/index"),
        hidden: true
    },
    {
        path: "/404",
        component: () =>
            import ("@/views/404"),
        hidden: true
    },

    // 首页
    {
        path: "/",
        component: Layout,
        name: "订单管理",
        alwaysShow: true,
        meta: { title: "订单管理", icon: "chart" },
        children: [{
            path: "orderManagement",
            component: () =>
                import ("@/views/orderManagement"),
            meta: { title: "订单管理", icon: "el-icon-platform-eleme" }
        }]
    },
    {
        path: "/orderProductDetails",
        component: Layout,
        name: "产品管理",
        alwaysShow: true,
        meta: { title: "产品管理", icon: "chart" },
        children: [{
            path: "",
            component: () =>
                import ("@/views/orderProductDetails/index"),
            name: "orderProductDetails",
            meta: { title: "产品管理" }
        }]
    },
    {
        path: "/manufacturing",
        // component: () => import('@/views/dispatchList/index'),
        component: Layout,
        name: "manufacturing",
        meta: { title: "生产管理", icon: "chart" },
        children: [{
                path: "engineering",
                component: () =>
                    import ("@/views/engineering/index"),
                name: "engineering",
                meta: { title: "工程工艺管理" }
            },
            {
                path: "dispatchList",
                component: () =>
                    import ("@/views/dispatchList/index"),
                name: "dispatchList",
                meta: { title: "项目总清单" }
            },
            {
                path: "purchaseList",
                component: () =>
                    import ("@/views/purchaseList/index"),
                name: "purchaseList",
                meta: { title: "采购申请" }
            }
            // {
            //     path: "purchaseList",
            //     component: () =>
            //         import ("@/views/purchaseList/index"),
            //     name: "purchaseList",
            //     meta: { title: "项目总清单" }
            // },
        ]
    },
    {
        path: "/pmList",
        component: Layout,
        name: "pmList",
        alwaysShow: true,
        meta: { title: "外协管理", icon: "chart" },
        children: [{
            path: "",
            component: () =>
                import ("@/views/pmList/index"),
            name: "pmlist",
            meta: { title: "外协列表" }
        }]
    },
    {
        path: "/platestoragelist",
        component: Layout,
        name: "仓库管理",
        alwaysShow: true,
        meta: { title: "仓库管理", icon: "chart" },
        children: [{
                path: "",
                component: () =>
                    import ("@/views/platestoragelist/index"),
                name: "platestoragelist",
                meta: { title: "仓库管理" }
            },
            {
                path: "record",
                component: () =>
                    import ("@/views/platestoragelist/record"),
                name: "platestoragelistRecord",
                meta: { title: "出入库记录" }
            }
        ]
    },
    {
        path: "/purchaseList",
        // component: () => import('@/views/requisitionList/index'),
        component: Layout,
        name: "采购管理",
        alwaysShow: true,
        meta: { title: "采购管理", icon: "chart" },
        children: [{
                path: "",
                component: () =>
                    import ("@/views/purchaseList/index"),
                name: "purchaseList",
                meta: { title: "采购" }
            },
            {
                path: "purchaseRecord",
                component: () =>
                    import ("@/views/purchaseList/record"),
                name: "purchaseRecord",
                meta: { title: "采购记录" }
            }
        ]
    },
    {
        path: "/qualityinspection",
        component: Layout,
        name: "qualityinspection",
        alwaysShow: true,
        meta: { title: "品检管理", icon: "chart" },
        children: [{
                path: "qualityinList",
                component: () =>
                    import ("@/views/qualityInspection/index"),
                name: "qualityinList",
                meta: { title: "品检列表" }
            },
            {
                path: "pmlist",
                component: () =>
                    import ("@/views/pmList/index"),
                name: "pmlist",
                meta: { title: "外协品检列表" }
            },
            {
                path: "quality-record",
                component: () =>
                    import ("@/views/qualityInspection/record"),
                name: "qualityRecord",
                meta: { title: "品检记录" }
            },

            {
                path: "productInspection",
                component: () =>
                    import ("@/views/productInspection/index"),
                name: "productInspection",
                meta: { title: "产品品检管理" }
            }
            // {
            //   path: 'quality-record',
            //   component: () =>
            //                   import('@/views/qualityInspection/record'),
            //   name: 'qualityRecord',
            //   meta: { title: '原材料品检管理' }
            // }
        ]
    },
    {
        path: "/jurisdiction",
        // component: () => import('@/views/personnelManagement/index'),
        component: Layout,
        name: "jurisdiction",
        meta: { title: "权限管理", icon: "chart" },
        children: [{
                path: "personnelManagement",
                component: () =>
                    import ("@/views/personnelManagement/index"),
                name: "personnelManagement",
                meta: { title: "人员管理" }
            },
            {
                path: "role",
                component: () =>
                    import ("@/views/role/index"),
                name: "role",
                meta: { title: "角色管理" }
            },
            {
                path: "/supplier",
                component: () =>
                    import ("@/views/supplier/index"),
                name: "供应商管理",
                alwaysShow: true,
                meta: { title: "供应商管理", icon: "chart" }
            },
            {
                path: "/customer",
                component: () =>
                    import ("@/views/customer/index"),
                name: "客户管理",
                alwaysShow: true,
                meta: { title: "客户管理", icon: "chart" }
            },
            {
              path: "/dic",
              component: () =>
                import ("@/views/sysdic/index"),
              name: "系统管理",
              alwaysShow: true,
              meta: { title: "系统管理", icon: "chart" }
            },
          {
            path: "/message",
            component: () =>
              import ("@/views/message/index"),
            name: "消息管理",
            alwaysShow: true,
            meta: { title: "消息管理", icon: "chart" }
          },
          {
            path: "/message/log",
            component: () =>
              import ("@/views/message/log"),
            name: "消息列表",
            alwaysShow: false,
            meta: { title: "消息列表", icon: "chart" }
          }

        ]
    },
    // {
    //   path: '/requisitionList',
    //   // component: () => import('@/views/requisitionList/index'),
    //   component: Layout,
    //   name: '请购清单',
    //   meta: { title: '请购清单', icon: 'chart' },
    //   children: [{
    //     path: '',
    //     component: () =>
    //                     import('@/views/requisitionList/index'),
    //     name: 'requisitionList',
    //     meta: { title: '请购清单' }
    //   }]
    // },
    // {
    //   path: '/orderFee',
    //   component: Layout,
    //   name: 'orderFee',
    //   meta: { title: '订单费用', icon: 'chart' },
    //   children: [{
    //     path: '',
    //     component: () =>
    //                     import('@/views/orderFee/index'),
    //     name: 'orderFee',
    //     meta: { title: '订单费用' }
    //   }]
    // },
    {
        path: "/outsourcing",
        component: Layout,
        name: "outsourcing",
        meta: { title: "外协", icon: "chart" },
        children: [{
            path: "",
            component: () =>
                import ("@/views/outsourcing/index"),
            name: "outsourcing",
            meta: { title: "外协" }
        }]
    }
    // {
    //   path: '/role',
    //   // component: () => import('@/views/personnelManagement/index'),
    //   component: Layout,
    //   name: 'role',
    //   meta: { title: '角色管理', icon: 'chart' },
    //   children: [{
    //     path: '',
    //     component: () =>
    //                     import('@/views/role/index'),
    //     name: 'role',
    //     meta: { title: '角色管理' }
    //   }]
    // }
];
/**
 * 动态路由
 */
// export const asyncRoutes = [
//   {
//     path: '/orderManagement',
//     component: Layout,
//     redirect: '/orderManagement',
//     name: '订单管理',
//     meta: { title: '订单管理', icon: 'chart' },
//     children: [

//     ]
//   },

//   { path: '*', redirect: '/404', hidden: true }
// ]

const createRouter = () =>
    new Router({
        // mode: 'history', // require service support
        scrollBehavior: () => ({ y: 0 }),
        routes: constantRoutes
    });

const router = createRouter();

// export default new Router({
//   // mode: 'history', //后端支持可开
//   scrollBehavior: () => ({ y: 0 }),
//   routes: constantRouterMap
// })

export default router;
